package com.atguigu.lease.common.context;

/**
 * @BelongsProject: lease
 * @BelongsPackage: com.atguigu.lease.common.context
 * @Author: jiangyi
 * @CreateTime: 2025-08-22  16:34
 * @Description: TODO
 * @Version: 1.0
 */
public class LoginUserContext {

    // 创建线程变量 也可直接使用 SystemUser
    private static final ThreadLocal<LoginUser> userThreadLocal = new ThreadLocal<>();
    // 静态方法直接访问
    public static void setLoginUser(LoginUser loginUser) {
        userThreadLocal.set(loginUser);
    }

    public static LoginUser getLoginUser() {
        return userThreadLocal.get();
    }

    public static void clear() {
        userThreadLocal.remove();
    }
}
